package com.tx.springboot_demo.controller;

import com.tx.springboot_demo.domain.IndexDomain;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.ArrayList;
import java.util.List;

/**
 * @author ：tx
 * @description：
 * @date ：Created in 2019/4/8 17:53
 * @modified By：
 * @version:
 */
@Controller
@RequestMapping("/jspController")
public class JspController {

    @RequestMapping("/jumpToJsp")
    public ModelAndView jumpToJsp(){
        ModelAndView mv = new ModelAndView("/jspIndex");
        List<IndexDomain> list = createIndexList();
        mv.addObject("jspList",list);
        return mv;
    }

    private List<IndexDomain> createIndexList(){
        List<IndexDomain> list = new ArrayList<>();
        IndexDomain i1 = new IndexDomain("石婷婷",18,"www.baidu.com");
        IndexDomain i2 = new IndexDomain("mercury",18,"www.alibaba.com");
        IndexDomain i3 = new IndexDomain("石婷婷",18,"www.baidu.com");
        list.add(i1);
        list.add(i2);
        list.add(i3);
        return list;
    }
}
